function Node(val) {
  this.value = val;
  this.left = null;
  this.right = null;
}

let a = new Node('a');
let b = new Node('b');
let c = new Node('c');
let d = new Node('d');
let e = new Node('e');
let f = new Node('f');
let g = new Node('g');

a.left = b;
a.right = c;
b.left = d;
b.right = e;
c.left = f;
c.right = g;


//前序

function flowFirst(root) {
  // return node.value
  // console.log(node.value, node.left);
  if (root == null) return;
  console.log(root.value);
  flowFirst(root.left)
  flowFirst(root.right)
}

// flowFirst(a)


// 中序

function flowMiddle(root) {
  if (root == null) return;
  flowMiddle(root.left);
  console.log(root.value);
  flowMiddle(root.right)
}

// flowMiddle(a)

// 后序

function flowAfter(root) {
  if (root == null) return;
  flowAfter(root.left);
  flowAfter(root.right)
  console.log(root.value);
}

flowAfter(a)



// 伪代码

function flow(a) {
  // left
  function flow(b) {
    // 前
    function flow(d) {
      // flow(root.left)
      // flow(root.right)
    }
    // 中
    flow(e)
  }
  flow(root.right)
}